package com.webtest.mvctest1;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2018/7/25 21:57
 */
public class ShowStudentListServlet extends HttpServlet {
    private static final long serialVersionUID = -9050064162062040804L;

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        StudentDao dao = new StudentDao();
        List<Student> students = dao.getAllStudentList();
        request.setAttribute("students", students);
        request.getRequestDispatcher("/student/showstudent.jsp").forward(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
